<template>
  <el-dialog v-model="dialog" title="修改采购商" width="800px" :close-on-click-modal="false">
    <div class="tabBox" v-loading="loading">
      <div style="margin-bottom: 10px;">企业名称：{{ compName }}</div>
      <el-table border :data="tableData">
        <el-table-column type="index" label="序号"></el-table-column>
        <el-table-column label="操作时间" prop="createTime" show-overflow-tooltip></el-table-column>
        <el-table-column label="操作人" prop="realName" show-overflow-tooltip></el-table-column>
        <el-table-column label="操作过程" prop="optType" show-overflow-tooltip></el-table-column>
        <el-table-column label="备注" prop="remark" show-overflow-tooltip></el-table-column>
        <el-table-column label="操作" v-if="isUse">
          <template v-slot="{ row }">
            <el-button type="text" style="color: #FF0000;" @click="delRecord(row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <template #footer>
      <el-button @click="dialog = false; tableData = []">关闭</el-button>
    </template>
  </el-dialog>
</template>

<script setup>
  
  import {
    ref,
    inject,
    getCurrentInstance
  } from 'vue'
  
  const $post = inject('$post');
  const $message = inject('$message');
  const $confirm = inject('$confirm');
  
  const tableData = ref([]);
  
  const isUse = ref(false);
  const loading = ref(false);
  
  const dialog = ref(false);
  
  const compName = ref('');
  
  const guid = ref('');
  
  const delRecord = row => {
    $confirm('确定删除该条操作？', '提示').then(_ => {
      $post('/tdltry/viste/reply', {
        guid: row.guid,
        replyContent: '',
        isReply: 0
      }).then(res => {
        getTableData(guid.value);
        $message.success('删除成功');
      })
    })
  }
  
  const getTableData = guid => {
    loading.value = true;
    $post('/v2/tdltry/addRecord/?guid=' + guid).then(res => {
      tableData.value = res.data.list;
      isUse.value = res.data.isUse;
    }).finally(_ => loading.value = false);
  }
  
  defineExpose({
    show: function (row) {
      compName.value = row.compName;
      guid.value = row.guid;
      dialog.value = true;
      getTableData(guid.value);
    }
  });
  
  
  
</script>

<style>
</style>
